package com.bdqn.service;
import com.bdqn.dao.SupplierMapper;
import com.bdqn.pojo.Supplier;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Transactional
@Service("supplierService") // 注册为一个Service层的Bean
public class SupplierServiceImpl implements SupplierService {
    @Autowired // @Resource
    private SupplierMapper supplierMapper;

    @Transactional(propagation = Propagation.SUPPORTS)

    @Override
    public List<Supplier> selectSupplier(Supplier supplier) {
        try {
            return supplierMapper.selectSupplier(supplier);
        } catch (RuntimeException e) {
            e.printStackTrace();
            throw e;
        }
    }
    @Transactional(propagation = Propagation.REQUIRED)
    @Override
    public boolean add(Supplier supplier) {
        supplierMapper.add(supplier);
        return true;
    }
    @Transactional(propagation = Propagation.REQUIRED)
    @Override
    public int delete(Integer id) {
        try {
            return supplierMapper.delete(id);
        } catch (RuntimeException e) {
            e.printStackTrace();
            throw e;
        }
    }
    @Transactional(propagation = Propagation.REQUIRED)
    @Override
    public boolean update(Supplier supplier) {
        supplierMapper.update(supplier);
        return true;
    }
}
